package cn.aitrox.ry.app.web.controller.config;

import cn.aitrox.ry.app.web.vo.config.common.out.MaxCodeOutVo;
import cn.aitrox.ry.bean.CommonPageInfo;
import cn.aitrox.ry.bean.RespResult;
import cn.aitrox.ry.service.config.dto.LesionDto;
import cn.aitrox.ry.service.config.dto.in.LesionCreateInDto;
import cn.aitrox.ry.service.config.dto.in.LesionEditInDto;
import cn.aitrox.ry.service.config.dto.in.LesionGroupSearchInDto;
import cn.aitrox.ry.service.config.dto.in.LesionSearchInDto;
import cn.aitrox.ry.service.config.feign.LesionFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class LesionController {

    @Autowired
    @Lazy
    private LesionFeign lesionFeign;

    @PostMapping(value = "/config/lesion/group/search")
    public RespResult<CommonPageInfo<LesionDto>> lesionGroupSearch(@RequestBody LesionGroupSearchInDto input) {
        CommonPageInfo<LesionDto> pageInfo = lesionFeign.lesionGroupSearch(input);
        return RespResult.ok(pageInfo);
    }

    @PostMapping(value = "/config/lesion/search")
    public RespResult<CommonPageInfo<LesionDto>> lesionSearch(@RequestBody LesionSearchInDto input) {
        CommonPageInfo<LesionDto> pageInfo = lesionFeign.lesionSearch(input);
        return RespResult.ok(pageInfo);
    }

    @PostMapping(value = "/config/lesion")
    public RespResult create(@Validated @RequestBody LesionCreateInDto input) {
        return lesionFeign.create(input);
    }

    @PutMapping(value = "/config/lesion")
    public RespResult edit(@Validated @RequestBody LesionEditInDto input) {
        return lesionFeign.edit(input);
    }

    @GetMapping(value = "/config/lesion/maxCode")
    public RespResult<MaxCodeOutVo> maxCode() {
        String maxCode = lesionFeign.maxCode();
        return RespResult.ok(new MaxCodeOutVo(maxCode));
    }

}
